﻿using Bilibili.Model.Collection;
using Bilibili.Model.Resource;
using Bilibili.WebClient.Common;
using PCLUntils.Json;
using System;
using System.Threading.Tasks;

namespace Bilibili.WebClient.Api
{
    public sealed class CollectionClient : ClientBase
    {
        public async Task<ReturnModel<GetUserFovBox>> GetFavType()
        {
            try
            {
                ApiInfo apiInfo = new ApiInfo("https://api.bilibili.com/medialist/gateway/base/created", $"&channel=bilih5&pn=1&ps=20&type=2&up_mid={ApiProvider.Instance.CurrentUserId}", true);
                var results = await ApiClient.GetResults(apiInfo);
                GetUserFovBox model = results.ParseObject<GetUserFovBox>();
                return BuildSuccessResult(model);
            }
            catch (Exception ex)
            {
                return BuildExceptionResult<GetUserFovBox>(ex);
            }
        }
        public async Task<ReturnModel<GetFavouriteBoxsVideoModel>> GetVideoFavBox(int fid, int pageNum)
        {
            try
            {
                ApiInfo apiInfo = new ApiInfo("http://api.bilibili.com/x/v2/fav/video", $"&pn={pageNum}&ps=20&tid=0&fid={fid}&vmid={ApiProvider.Instance.CurrentUserId}&order=ftime", true);
                var results = await ApiClient.GetResults(apiInfo);
                GetFavouriteBoxsVideoModel model = results.ParseObject<GetFavouriteBoxsVideoModel>();
                return BuildSuccessResult(model);
            }
            catch (Exception ex)
            {
                return BuildExceptionResult<GetFavouriteBoxsVideoModel>(ex);
            }
        }
    }
}